package zut.edu.cs.network.io.print;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

import org.junit.Test;

public class PrintReaderDemo {

	public static void main(String[] args) {
		FileReader fr;
		try {
			fr = new FileReader("test.txt");
			BufferedReader br = new BufferedReader(fr);
			
			FileWriter fw = new FileWriter("copy.txt");
			PrintWriter pw = new PrintWriter(fw);
			
			String string = br.readLine();
			while (string != null) {
				pw.println(string);
				string = br.readLine();
			}
			
			pw.close();
			br.close();
			fw.close();
			fr.close();
			System.out.println("复制成功！");
			
		} catch (FileNotFoundException e) {
			System.out.println("文件不存在！");
			e.printStackTrace();
		} catch (IOException e) {
			System.out.println("读取文件异常！");
			e.printStackTrace();
		}
		

	}

}
